package com.qingzhou.web.controller.edc;

import com.mybatisflex.core.paginate.Page;
import com.qingzhou.common.enums.BusinessType;
import com.qingzhou.common.web.controller.BaseController;
import com.qingzhou.framework.annotation.QzLog;
import com.qingzhou.web.repository.entity.SurgeryEntity;
import com.qingzhou.web.service.EdcConstants;
import com.qingzhou.web.service.SurgeryService;
import com.qingzhou.web.service.impl.params.request.*;
import com.qingzhou.web.service.impl.params.vo.SurgeryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.noear.solon.annotation.*;
import org.noear.solon.core.handle.Result;

@Api(EdcConstants.EDC_SURGERY)
@Controller
@Mapping("edc/surgery")
public class SurgeryController extends BaseController {

    @Inject
    SurgeryService surgeryService;


    @ApiOperation("新增"+EdcConstants.EDC_SURGERY)
    @QzLog(title = "新增"+EdcConstants.EDC_SURGERY, businessType = BusinessType.INSERT)
    //@AuthPermissions("edc:surgery:add")
    @Post
    @Mapping("add")
    public Result<Void> add(SurgeryAddForm form) {
        return toResult(surgeryService.add(form));
    }

    @ApiOperation("删除"+EdcConstants.EDC_SURGERY)
    @QzLog(title = "删除"+EdcConstants.EDC_SURGERY, businessType = BusinessType.DELETE)
    //@AuthPermissions("edc:surgery:delete")
    @Post
    @Mapping("delete")
    public Result<Void> delete(SurgeryDeleteForm form) {
        return toResult(surgeryService.delete(form));
    }

    //@AuthPermissions("edc:surgery:page")
    @Post
    @Mapping("page")
    @ApiOperation(EdcConstants.EDC_SURGERY+"分页")
    public Page<SurgeryVo> page(Page<SurgeryEntity> page, SubTablePageForm form) {
        return surgeryService.page(page, form);
    }

    //@AuthPermissions("edc:surgery:detail")
    @Get
    @Mapping("detail")
    @ApiOperation(EdcConstants.EDC_SURGERY+"详情")
    public SurgeryVo detail(SurgeryDetailForm form) {
        return surgeryService.detail(form);
    }

    @ApiOperation("编辑"+EdcConstants.EDC_SURGERY)
    @QzLog(title = "编辑"+EdcConstants.EDC_SURGERY, businessType = BusinessType.INSERT)
    //@AuthPermissions("edc:surgery:edit")
    @Post
    @Mapping("edit")
    public Result<Void> edit(SurgeryEditForm form) {
        return toResult(surgeryService.edit(form));
    }

    @ApiOperation("数据检查"+EdcConstants.EDC_SURGERY)
    @QzLog(title = "数据检查"+EdcConstants.EDC_SURGERY, businessType = BusinessType.INSERT)
    //@AuthPermissions("edc:surgery:forceEdit")
    @Post
    @Mapping("forceEdit")
    public Result<Void> forceEdit(SurgeryForceEditForm form) {
        return toResult(surgeryService.forceEdit(form));
    }

    @ApiOperation("核实"+EdcConstants.EDC_SURGERY)
    @QzLog(title = "核实"+EdcConstants.EDC_SURGERY, businessType = BusinessType.INSERT)
    //@AuthPermissions("edc:surgery:done")
    @Post
    @Mapping("done")
    public Result<Void> done(SurgeryDoneForm form) {
        return toResult(surgeryService.done(form));
    }

    @ApiOperation("终止"+EdcConstants.EDC_SURGERY)
    @QzLog(title = "终止"+EdcConstants.EDC_SURGERY, businessType = BusinessType.INSERT)
    //@AuthPermissions("edc:surgery:stop")
    @Post
    @Mapping("stop")
    public Result<Void> stop(SurgeryStopForm form) {
        return toResult(surgeryService.stop(form));
    }
}
